home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / MonitorSimMux.cc,v < prev    next >
Text File  |  1989-03-23  |  2KB  |  133 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @@;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.36.13;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.49.00;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     88.10.30.13.03.13;  author grunwald;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 3.2
  30. log
  31. @Start using Gnu library heaps for schedulers
  32. @
  33. text
  34. @// This may look like C code, but it is really -*- C++ -*-
  35. // 
  36. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  37. //
  38. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  39. //
  40. #include "MonitorSimMux.h"
  41. #include "SpinBarrier.h"
  42. #include "Statistic.h"
  43. #include "SpinFetchAndOp.h"
  44. #include "Config.h"
  45.  
  46. static SpinLock statsLock;
  47. static Statistic ThreadsPerTick;
  48. static int threadsThisTick[MaxCpuMultiplexors];
  49.  
  50. extern int CpuMuxDebugFlag;
  51.  
  52. MonitorSimMux *ThisMonitorSimMux;
  53.  
  54. MonitorSimMux::MonitorSimMux(int debug, int maxloops) : (debug, maxloops)
  55. {
  56.     pNameTemplate = "MonitorSimMux";
  57.     ThisMonitorSimMux = this;
  58.     sprintf(nameSpace, "[%s-%d] ", pNameTemplate, iYam);
  59.     pName = nameSpace;
  60. }
  61.  
  62. void
  63. MonitorSimMux::stirItAround()
  64. {
  65.     while( ! *terminated )
  66.     {
  67.     CpuMultiplexor::stirItAround();
  68. #ifndef NDEBUG
  69.     if (CpuMuxDebugFlag) {
  70.         CpuCerrLock.reserve();
  71.         cerr << name() << "Finished with current batch, advance time\n";
  72.         CpuCerrLock.release();
  73.     }
  74. #endif /*NDEBUG*/
  75.     int added = advanceTime();
  76.  
  77.     threadsThisTick[iYam] += added;
  78.  
  79.     cpuBarrier -> rendezvous();
  80.  
  81.     if (iYam == 0) {
  82.         int total = 0;
  83.         for (int i = 0 ; i < CpuMultiplexors; i++ ) {
  84.         total += threadsThisTick[i];
  85.         threadsThisTick[i] = 0;
  86.         }
  87.         double dtotal = double(total);
  88.         ThreadsPerTick += dtotal;
  89.     }
  90.     }
  91. }
  92.  
  93. void
  94. MonitorSimMux::coolItDown()
  95. {
  96.     SimulationMultiplexor::coolItDown();
  97.     
  98.     CpuCerrLock.reserve();
  99.     cerr << name() << "Statistics for threads per tick\n";
  100.     cerr << name() << ThreadsPerTick << "\n";
  101.     cerr << name() << "Min = " << ThreadsPerTick.min() << "\n";
  102.     cerr << name() << "Max = " << ThreadsPerTick.max() << "\n";
  103.     CpuCerrLock.release();
  104. }
  105.  
  106. Statistic *
  107. MonitorSimMux::threadsPerTick()
  108. {
  109.     return (&ThreadsPerTick);
  110. }
  111. @
  112.  
  113.  
  114. 3.1
  115. log
  116. @Steay version
  117. @
  118. text
  119. @@
  120.  
  121.  
  122. 1.1
  123. log
  124. @Initial revision
  125. @
  126. text
  127. @d21 1
  128. a21 1
  129. MonitorSimMux::MonitorSimMux(int debug) : (debug)
  130. d23 1
  131. d25 2
  132. @
  133.